<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Ajax练习</title>
    <link href="css/bootstrap-3.3.6.min.css" rel="stylesheet">
    <script src="js/jquery-2.2.0.js"></script>

    <style>
        body {
            font-family: "微软雅黑";
            font-size: 1.6em;
            color: #02177c;
            background: #b3d6ff;
        }
        a, .glyphicon {
            cursor: pointer;
            margin-right: 5px;
        }
        h3{
            text-align: center;
        }

    </style>
</head>
<body>
<div class="container">
    <br>
    <h1>Ajax练习</h1>
    <hr>
    <br>
    <h3>js实现Ajax</h3>
    <div class="row" id="fontSize">
        <div class="col-md-6 col-md-offset-3">
            <button class="btn btn-success" onclick="Ajax()">Ajax提交</button>
            <br><br>
            <div id="resText"></div>
        </div>
    </div>
    <div style="height: 500px"></div>
</div>
<script>
function Ajax(){

    var xmlHttpReq = new XMLHttpRequest();
//    xmlHttpReq.open("GET","jsAjaxTestServlet",true);
    xmlHttpReq.open("GET","ajax/jsTest",true);
    xmlHttpReq.onreadystatechange = RequestCallBack;
    xmlHttpReq.send();
    function RequestCallBack(){
        if (xmlHttpReq.status == 200 && xmlHttpReq.readyState ==4){
            document.getElementById("resText").innerHTML = xmlHttpReq.responseText;
        }
    }

}


</script>
<!--<div style="background: rgba(164, 255, 169, 0.34)">.</div>-->
</body>
</html>